package com.example.rule.core;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author Jason - Chusifeng
 * @version 1.0.0
 * @ClassName Rules.java
 * @PackageName com\welab\vb\payment\transaction\rule\core\Rules.java
 * @Description 加载所有规则
 * @createTime 2022年10月10日 10:48:42
 */
public class Rules implements Iterable<Rule>{

    private Set<Rule> rules = new TreeSet<>();

    public Rules(List<Rule> rules) {
        this.rules = new TreeSet<>(rules);
    }

    public Rules(Rule... rules) {
        Collections.addAll(this.rules, rules);
    }
    public void addRule(Rule rule){
        rules.add(rule);
    }
    public boolean isEmpty() {
        return rules.isEmpty();
    }

    public int size(){
        return rules.size();
    }

    public void clear() {
        rules.clear();
    }

    @Override
    public Iterator<Rule> iterator() {
        return rules.iterator();
    }

}
